#include "../include/head.h"

int makeworker(shareRes_t *share, pthread_data_t *pthread_data, Client_info *clientInfo, int *exitFlag, pthread_mutex_t *mutex_client_info, pthread_mutex_t *mysql_mutex, pthread_mutex_t *long_queue_mutex,pthread_cond_t* long_queue_cond, pthread_mutex_t *short_queue_mutex,pthread_cond_t*short_queue_cond,taskQueue_t *queue_arr, int *epfd)
{
    for (int i = 0; i < pthread_data->workernum;i++)
    {
        share[i].pthread_data = pthread_data;
        share[i].pclient_info = clientInfo;// 指向client_info全局结构体
        share[i].exitflag=exitFlag;
        share[i].mutex_client_info=mutex_client_info;
        share[i].mysql_mutex = mysql_mutex;
        if(i==0)
        {
            share[i].taskqueue = &queue_arr[0];
            share[i].mutex_taskqueue = short_queue_mutex;
            share[i].cond = short_queue_cond;
        }
        if(i>0)
        {
            share[i].taskqueue = &queue_arr[1];
            share[i].mutex_taskqueue = long_queue_mutex;
            share[i].cond = long_queue_cond;
        }
        share[i].epfd = epfd;
        

        pthread_create(&share[i].pthread_data->ptidarr[i], NULL, pthread_enter, &share[i]);
    }

    return 0;

}
